# Contributor: TBK <alpin@jjtc.eu>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=protobuf-c
pkgver=1.4.1
pkgrel=7
pkgdesc="Protocol Buffers implementation in C"
url="https://github.com/protobuf-c/protobuf-c"
arch="all"
license="BSD-2-Clause"
depends_dev="$pkgname-compiler=$pkgver-r$pkgrel"
makedepends="autoconf automake libtool abseil-cpp-dev protobuf-dev"
subpackages="$pkgname-compiler $pkgname-dev"
source="https://github.com/protobuf-c/protobuf-c/releases/download/v$pkgver/protobuf-c-$pkgver.tar.gz
	protobuf-23.patch
	"

# secfixes:
#   1.4.1-r0:
#     - CVE-2022-33070
#   1.3.2-r0:
#     - CVE-2021-3121

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	CXXFLAGS="$CXXFLAGS -std=c++17 -flto=auto" \
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
}

compiler() {
	pkgdesc="Protocol Buffers C compiler"

	amove usr/bin/protoc-c
	amove usr/bin/protoc-gen-c
}

sha512sums="
190a4aa5c607853e6bf860b0974deb21e4f7f6209e810251eaca9612b59ea676779b0ca217fb1572914ffb8de3315a7d24f162b14d447ee671a9adc5b1271e41  protobuf-c-1.4.1.tar.gz
79ce6f677800bb7e6e04adf08a4cb43381dd179471fff460cf473ec513c750bf772cc627ef26da9d0487317a53fa134dabad6236d16d5e0cf9421f13a4207b45  protobuf-23.patch
"
